package swd.work.conf_form_fields_detail;

import java.util.*;

import com.pub.database.*;
import swd.base.*;

public class Business extends SwdBase{
    QueryBean gqbnDAO=null;
    public Business(QueryBean pqbnDAO){
        super(null,null,pqbnDAO);
        gqbnDAO=pqbnDAO;

   }
   String getDataViewHtml(DataView dataView,DataViewForm DataViewForm,View view,String pstrLoginUser) throws Exception{

       String strDataViewHtml=null;
       StringBuffer stbCondition = new StringBuffer();
       StringBuffer stbPageActionURI = new StringBuffer("conf_form_fields_detail.jsp?prgAction=&frm_no=" + view.getfrm_no() + "&prg_no=" +view.getprg_no());

       DataViewForm.setTablesList(" wkf_frm1 ");

       if(view.getfrm_no()==null || view.getfrm_no().trim().equals("")){
           view.setfrm_no(gqbnDAO.readSingleValueData("select min(frm_no) from wkf_frm1 where prg_no='" + view.getprg_no() + "'"));
       }

       stbCondition.append(" prg_no='");
       stbCondition.append(view.getprg_no());
       stbCondition.append("' and frm_no='");
       stbCondition.append(view.getfrm_no());
       stbCondition.append("'");

       DataViewForm.setSQLCondition(stbCondition.toString());
       DataViewForm.setOrderByFields("seqno");
       DataViewForm.setOrderBySeq("asc");
       DataViewForm.setGroupBy(null);
       DataViewForm.setHaving(null);

       //Hashtable lhtColRelation=new Hashtable();
       ArrayList<Hashtable<String,Object>> laltColRelation=new ArrayList<Hashtable<String,Object>>();
       Hashtable<String,Object> lhtColRelationDetail=new Hashtable<String,Object>();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"'Del' as del");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'Del'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"rowSpan='3' width='3%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='checkbox' name='willDel' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"'%sn%'");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='checkbox' name='willDel' value='' onclick='if(this.checked){this.value=(DataViewTableBody.rows.length/3)-1}'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"SEQNO");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'欄序'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"rowSpan='3' width='3%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='2' name='seqno' readonly class='input_noborder' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='2' name='seqno' class='input' value='Ins'/>");//使用全形空白
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"SEQNO");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"RW_MODE");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'編輯方式'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"SELECT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='middle'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<SELECT class='input' NAME=\"rw_mode\">");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,this.getRwModeList());
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<SELECT class='input' NAME='rw_mode'><option value='H'>HIDDEN</option><option value='F'>FILE</option><option value='T'>TEXT BOX</option><option value='B'>BUTTON</option><option value='C'>CHECK BOX</option><option value='R'>RADIO BUTTON</option><option value='L'>LINK</option><option value='E'>RESET</option><option value='S'>SUBMIT</option><option value='A'>NOTE LINE</option><option value='D'>DROP-DOWN</option><option value='M'>TEXTAREA</option><option value='N'>RICHTEXT</option><option value='V'>SHOW</option></select></select>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"LINK_FLD");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'串主檔欄'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='link_fld' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"LINK_FLD");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='link_fld' value='LINK_FLD'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"FLD_KIND");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'資料型態'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"SELECT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<SELECT class='input' NAME='fld_kind'>");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,this.getFldKindList());
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<SELECT class='input' NAME='fld_kind'><option value='C'>文字</option><option value='N'>數字</option><option value='D'>日期</option><option value='L'>LongRaw</option></select>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"FLD_LEN");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'長度'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='fld_len' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"FLD_LEN");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='fld_len' value='0'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"FLD_MAX_LEN");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'限'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='fld_max_len' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"FLD_MAX_LEN");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='fld_max_len' value='0'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       /*lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"NOT_NULL_YN");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'欄位必填'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='not_null_yn' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"NOT_NULL_YN");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='not_null_yn' value='NOT_NULL_YN'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();*/

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"NOT_NULL_CNDT");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'必填條件'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='not_null_cndt' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"NOT_NULL_CNDT");
       lhtColRelationDetail.put(dataView.STR_FIELD_LINE_FEED,"true");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='not_null_cndt' value='NOT_NULL_CNDT'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"FLD_NO");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'欄位名稱'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='fld_no' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"FLD_NO");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='fld_no' value='FLD_NO'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"LINK_KIND");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'連動動作'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='link_kind' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"LINK_KIND");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='link_kind' value='LINK_KIND'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"DD_NO");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'輔助設定'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='dd_no' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"DD_NO");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='dd_no' value='DD_NO'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"DD_DATA");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'參數設定'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='dd_data' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"DD_DATA");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='dd_data' value='DD_DATA'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"LOG_YN");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'Log'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='log_yn' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"LOG_YN");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='log_yn' value='LOG_YN'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       /*lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"READONLY_YN");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'欄位唯讀'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='readonly_yn' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"READONLY_YN");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='readonly_yn' value='READONLY_YN'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();*/

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"PROTECT_CNDT");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'唯讀條件'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='protect_cndt' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"PROTECT_CNDT");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='protect_cndt' value='PROTECT_CNDT'/>");
       lhtColRelationDetail.put(dataView.STR_FIELD_LINE_FEED,"true");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"FLD_TITLE_C");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'中文名稱'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='fld_title_c' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"FLD_TITLE_C");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='fld_title_c' value='FLD_TITLE_C'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"FLD_TITLE_E");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'英文名稱'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='fld_title_e' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"FLD_TITLE_E");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='fld_title_e' value='FLD_TITLE_E'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"INIT_VALUE");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'欄位初始設定'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"colSpan='3' WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='77' maxlength='40' name='init_value' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"INIT_VALUE");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='77' maxlength='40' name='init_value' value='INIT_VALUE'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       /*lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"FLD_HIDDEN_YN");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'欄位隱藏'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='fld_hidden_yn' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"FLD_HIDDEN_YN");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='fld_hidden_yn' value='FLD_HIDDEN_YN'/>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();*/

       lhtColRelationDetail.put(dataView.STR_FIELD_NAME,"FLD_HIDDEN_CNDT");
       lhtColRelationDetail.put(dataView.STR_FIELD_TITLE,"'隱藏條件'");
       lhtColRelationDetail.put(dataView.STR_FIELD_KIND,"INPUT");
       lhtColRelationDetail.put(dataView.STR_FIELD_PROPERTY,"WIDTH='10%' align='center'");
       lhtColRelationDetail.put(dataView.STR_FIELD_HTML,"<input type='text' size='20' maxlength='40' name='fld_hidden_cndt' value=");
       lhtColRelationDetail.put(dataView.STR_FIELD_VALUE,"FLD_HIDDEN_CNDT");
       lhtColRelationDetail.put(dataView.STR_FIELD_APPEND_ROW_HTML,"<input type='text' size='20' maxlength='40' name='fld_hidden_cndt' value='FLD_HIDDEN_CNDT'>");

       laltColRelation.add(new Hashtable<String,Object>(lhtColRelationDetail));
       lhtColRelationDetail.clear();

       DataViewForm.setColRelationUseArrayList(laltColRelation);//將欄位相關設定殖入ActionForm
       DataViewForm.setSubmitMethod("POST");
       DataViewForm.setPageRowCount(0);
       DataViewForm.setJumpPageButtonShow(true);   //是否要秀出上下頁按鈕
       DataViewForm.setPageBtnOnTop(false);         //將button and rows info 秀在頂端
       DataViewForm.setPageBtnOnButtom(true);      //將button and rows info 秀在底端
       DataViewForm.setFilterShow(false);           //是否要秀出過濾選擇欄位
       DataViewForm.setJumpPageShow(false);         //是否要秀出跳頁下拉式選單
       DataViewForm.setRowsInfoShow(false);         //是否要秀出筆數資訊
       DataViewForm.setRowPageShow(false);          //是否要秀出每頁筆數控制欄
       DataViewForm.setExcelShow(false);           //是否要秀出轉Excel button
       DataViewForm.setOrderEnable(false);          //是否要提供排序點選功能
       DataViewForm.setShowHeaderWhenNoData(true);//當ResultSet無資料是否要秀Header
       DataViewForm.setHeaderFix(false);
       DataViewForm.setAddNewShow(true);
       DataViewForm.setTableDataHeight("500px");

       DataViewForm.setTableHeaderHtml("class='td_head_grid' align='center'  width='680px'");
       DataViewForm.setTableDataTrHtml("onmousedown=\"javascript:varSn=',%sn%';if(document.DataViewForm.changeRowNum.value.indexOf(varSn)<0){document.DataViewForm.changeRowNum.value=document.DataViewForm.changeRowNum.value + (document.DataViewForm.changeRowNum.value=='' ? varSn.substring(1) : varSn);}\"");
             //設定上一頁與下一頁按鈕的form action(通常為母頁即本頁)
       DataViewForm.setPageActionURI(stbPageActionURI.toString());

       strDataViewHtml=dataView.getOutputDataView(DataViewForm);

       return strDataViewHtml;
   }

   private String getRwModeList(){
       StringBuffer lstbFldKindList=new StringBuffer();

       lstbFldKindList.append("<option value=\"H\">");
       lstbFldKindList.append("HIDDEN");
       //lstbFldKindList.append(FormatFunction.getRepeatStr("　",8));
       lstbFldKindList.append("</option>,");
       lstbFldKindList.append("<option value=\"F\">FILE</option>,");
       lstbFldKindList.append("<option value=\"T\">TEXT BOX</option>,");
       lstbFldKindList.append("<option value=\"B\">BUTTON</option>,");
       lstbFldKindList.append("<option value=\"C\">CHECK BOX</option>,");
       lstbFldKindList.append("<option value=\"R\">RADIO BUTTON</option>,");
       lstbFldKindList.append("<option value=\"L\">LINK</option>,");
       lstbFldKindList.append("<option value=\"E\">RESET</option>,");
       lstbFldKindList.append("<option value=\"S\">SUBMIT</option>,");
       lstbFldKindList.append("<option value=\"A\">NOTE LINE</option>,");
       lstbFldKindList.append("<option value=\"D\">DROP-DOWN</option>,");
       lstbFldKindList.append("<option value=\"M\">TEXTAREA</option>,");
       lstbFldKindList.append("<option value=\"N\">RICHTEXT</option>,");
       lstbFldKindList.append("<option value=\"V\">SHOW</option>");

       return lstbFldKindList.toString();
   }

   private String getFldKindList(){
       StringBuffer lstbFldKindList=new StringBuffer();

       lstbFldKindList.append("<option value=\"C\">文字</option>,");
       lstbFldKindList.append("<option value=\"N\">數字</option>,");
       lstbFldKindList.append("<option value=\"D\">日期</option>,");
       lstbFldKindList.append("<option value=\"L\">LongRaw</option>");

       return lstbFldKindList.toString();
   }
   String batchUpdateData(View view) throws Exception{
       String[] lstrRowSn=view.getChangeRowNum().split(",");

       try{
           for(int i=0;i<lstrRowSn.length;i++){
               //先判斷該筆是否非新增的且要刪除!!(因有可能前端按了新增或進行修改後又決定不要這筆了)
               if(!view.getDataview_row_status()[Integer.parseInt(lstrRowSn[i])/3].equals("I") && (view.getWillDel()!=null && view.getWillDel()[Integer.parseInt(lstrRowSn[i])/3]!=null && !view.getWillDel()[Integer.parseInt(lstrRowSn[i])/3].equals(""))){
                   if (!exeDelSQL(view, Integer.parseInt(lstrRowSn[i]) / 3)) {
                       throw new Exception("delete error");
                   }
               }
               else{
                   if (view.getDataview_row_status()[Integer.parseInt(lstrRowSn[
                           i])/3].equals("I")) { //新增
                       if (!exeInsSQL(view, Integer.parseInt(lstrRowSn[i])/3)) {
                           throw new Exception("insert error");
                       }
                   } else {
                       if (!exeUpdSQL(view, Integer.parseInt(lstrRowSn[i])/3)) {
                           throw new Exception("update error");
                       }
                   }
               }

           }
           return "儲存成功!";
       }
       catch(Exception e){
           return "儲存失敗!!";
       }
   }

    /**
     * exeDelSQL
     *
     * @param view View
     * @param pintRowSn int
     */
    boolean exeDelSQL(View view, int pintSn) throws Exception{
        String lstrSQL=new String();
        try{
            lstrSQL="delete from wkf_frm1 where prg_no=" + view.getprg_no() + "' and frm_no='" + view.getfrm_no() + "' and seqno='" + view.getSeqno()[pintSn] + "'";

            return gqbnDAO.executeSQL(lstrSQL);
        }
        catch(Exception e){
            throw new Exception(e);
        }
    }

    boolean exeInsSQL(View view,int pintSn) throws Exception{
        String lstrSQL=new String();
        Vector<Object> lvtrParam = new Vector<Object>();

        try{
            lstrSQL="insert into wkf_frm1(prg_no,frm_no,seqno,fld_title_c,fld_title_e,fld_no,rw_mode,fld_kind,fld_len,fld_max_len) values";
            lstrSQL=lstrSQL + DBFunction.addQuemark(lstrSQL);

            lvtrParam.add(view.getprg_no()==null ? null : String.valueOf(view.getprg_no()));
            lvtrParam.add(view.getfrm_no()==null ? null : String.valueOf(view.getfrm_no()));
            lvtrParam.add(view.getSeqno()[pintSn]==null ? null : String.valueOf(view.getSeqno()[pintSn]));
            lvtrParam.add(view.getFld_title_c()[pintSn]==null ? null : String.valueOf(view.getFld_title_c()[pintSn]));
            lvtrParam.add(view.getFld_title_e()[pintSn]==null ? null : String.valueOf(view.getFld_title_e()[pintSn]));
            lvtrParam.add(view.getFld_no()[pintSn]==null ? null : String.valueOf(view.getFld_no()[pintSn]));
            lvtrParam.add(view.getRw_mode()[pintSn]==null ? null : String.valueOf(view.getRw_mode()[pintSn]));
            lvtrParam.add(view.getFld_kind()[pintSn]==null ? null : String.valueOf(view.getFld_kind()[pintSn]));
            lvtrParam.add(view.getFld_len()[pintSn]==null ? null : String.valueOf(view.getFld_len()[pintSn]));
            lvtrParam.add(view.getFld_max_len()[pintSn]==null ? null : String.valueOf(view.getFld_max_len()[pintSn]));

            return gqbnDAO.executeSQL(lstrSQL,lvtrParam);
        }
        catch(Exception e){
            throw new Exception(e);
        }
        finally{
            lvtrParam.clear();
            lvtrParam=null;
        }
    }

    boolean exeUpdSQL(View view,int pintSn) throws Exception{
      String lstrSQL=new String();
      Vector<Object> lvtrParam = new Vector<Object>();
      try{
          lvtrParam.add(view.getRw_mode()[pintSn]==null ? null :String.valueOf(view.getRw_mode()[pintSn]));
          lvtrParam.add(view.getLink_fld()[pintSn]==null ? null :String.valueOf(view.getLink_fld()[pintSn]));
          lvtrParam.add(view.getFld_kind()[pintSn]==null ? null :String.valueOf(view.getFld_kind()[pintSn]));
          lvtrParam.add(view.getFld_len()[pintSn]==null ? null :String.valueOf(view.getFld_len()[pintSn]));
          lvtrParam.add(view.getFld_max_len()[pintSn]==null ? null :String.valueOf(view.getFld_max_len()[pintSn]));
          //lvtrParam.add(view.getNot_null_yn()[pintSn]==null ? null :String.valueOf(view.getNot_null_yn()[pintSn]));
          lvtrParam.add(view.getNot_null_cndt()[pintSn]==null ? null :String.valueOf(view.getNot_null_cndt()[pintSn].toUpperCase()));
          lvtrParam.add(view.getFld_no()[pintSn]==null ? null :String.valueOf(view.getFld_no()[pintSn]));
          lvtrParam.add(view.getLink_kind()[pintSn]==null ? null :String.valueOf(view.getLink_kind()[pintSn]));
          lvtrParam.add(view.getDd_no()[pintSn]==null ? null :String.valueOf(view.getDd_no()[pintSn]));
          lvtrParam.add(view.getDd_data()[pintSn]==null ? null :String.valueOf(view.getDd_data()[pintSn]));
          lvtrParam.add(view.getLog_yn()[pintSn]==null ? null :String.valueOf(view.getLog_yn()[pintSn]));
          //lvtrParam.add(view.getReadonly_yn()[pintSn]==null ? null :String.valueOf(view.getReadonly_yn()[pintSn]));
          lvtrParam.add(view.getProtect_cndt()[pintSn]==null ? null :String.valueOf(view.getProtect_cndt()[pintSn]));
          lvtrParam.add(view.getFld_title_c()[pintSn]==null ? null :String.valueOf(view.getFld_title_c()[pintSn]));
          lvtrParam.add(view.getFld_title_e()[pintSn]==null ? null :String.valueOf(view.getFld_title_e()[pintSn].toUpperCase()));
          lvtrParam.add(view.getInit_value()[pintSn]==null ? null :String.valueOf(view.getInit_value()[pintSn]));
          //lvtrParam.add(view.getFld_hidden_yn()[pintSn]==null ? null :String.valueOf(view.getFld_hidden_yn()[pintSn]));
          lvtrParam.add(view.getFld_hidden_cndt()[pintSn]==null ? null :String.valueOf(view.getFld_hidden_cndt()[pintSn]));
          lstrSQL="update wkf_frm1 " +
                  "   set RW_MODE=?,LINK_FLD=?,FLD_KIND=?,FLD_LEN=?,FLD_MAX_LEN=?," +
                  "       NOT_NULL_CNDT=?,FLD_NO=?,LINK_KIND=?,DD_NO=?,DD_DATA=?, " +
                  "       LOG_YN=?,PROTECT_CNDT=?,FLD_TITLE_C=?,FLD_TITLE_E=?," +
                  "       INIT_VALUE=?,FLD_HIDDEN_CNDT=? " +
                  " where prg_no='" + view.getprg_no() + "'" +
                  "   and frm_no='" + view.getfrm_no() + "'" +
                  "   and seqno='" + view.getSeqno()[pintSn] + "'";

         return gqbnDAO.executeSQL(lstrSQL,lvtrParam);
      }
      catch(Exception e){
         throw new Exception(e);
      }
      finally{
         lvtrParam.clear();
         lvtrParam=null;
      }
   }

   Hashtable<String,Object> readQueryData(String pstrPrgNo) throws Exception{
       return gqbnDAO.readSingleRowData("select dbf_no,frm_name,prg_no from wkf_frm0 where prg_no='" + pstrPrgNo + "'");
   }

   boolean setQueryData(View view,Hashtable<String,Object> phtQueryData) throws Exception{
       if(phtQueryData==null){
           return false;
       }

       java.util.Enumeration<String> enuKeys= phtQueryData.keys();
       StringBuffer lstbMethodName=new StringBuffer();
       Object[] args = new Object[1];
       String lstrKeyName=null;

       while (enuKeys.hasMoreElements()) {
           lstrKeyName=enuKeys.nextElement().toString();
           lstbMethodName.append("set");
           lstbMethodName.append(lstrKeyName.toLowerCase());//getter and setter method name 都是小寫的
           args[0]=phtQueryData.get(lstrKeyName);//要寫入view.setXXX的內容值
           view.getClass().getMethod(lstbMethodName.toString(),new Class[]{String.class}).invoke(view,args);//透過Reflection將值寫入view.setXXX
           lstbMethodName.delete(0,lstbMethodName.length());
       }

       return true;
   }

   void setBtnShowMode(View view,String pstrPrgAction,String pstrPrgStatus){
       view.setBtnApproveShow("none");
       view.setBtnCancelShow("none");
       view.setBtnDraftShow("none");
       view.setBtnModifyShow("none");
       view.setBtnRejectShow("none");
       view.setBtnTraceShow("none");
       view.setBtnUpdateShow("none");
       view.setBtnSaveShow("none");
       view.setBtnAddShow("none");
       view.setBtnDeleteShow("none");
   }
}
